package com.magic.ch02_二分与前缀和.数的范围;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pr = new PrintWriter(System.out);
        String[] read = br.readLine().split(" ");
        int n = Integer.parseInt(read[0]);
        int m = Integer.parseInt(read[1]);
        int[] q = new int[n + 5];
        read = br.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            q[i] = Integer.parseInt(read[i]);
        }
        for (int i = 0; i < m; i++) {
            int x = Integer.parseInt(br.readLine());
            int l = 0, r = n - 1;
            while (l < r) {
                int mid = l + r >> 1;
                if (q[mid] >= x) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }
            if (q[r] == x) {
                pr.print(r + " ");
                r = n - 1;
                while (l < r) {
                    int mid = l + r + 1 >> 1;
                    if(q[mid] <= x){
                        l = mid;
                    }else{
                        r = mid - 1;
                    }
                }
                pr.println(r);
            }else{
                pr.println("-1 -1");
            }
        }
        br.close();
        pr.flush();
        pr.close();
    }
}
